package cn.wolfcode.service.impl;

import cn.wolfcode.domain.User;
import cn.wolfcode.mapper.UserMapper;
import cn.wolfcode.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;


@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public User login(String username, String password) {
        if (!StringUtils.hasLength(username)){
            return null;
        }
        if (!StringUtils.hasLength(password)){
            return null;
        }

        QueryWrapper<User> wrapper = new QueryWrapper();
        wrapper.eq("username",username).eq("password",password);
        return super.getOne(wrapper);

    }
}
